import 'dart:convert';

import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_ulog/src/i_ulog_format_strategy.dart';
import 'package:flutter_ulog/src/ulog.dart';
import 'package:flutter_ulog/src/ulog_console_adapter.dart';


class consoleAdapter extends ULogConsoleAdapter{
  @override
  bool isLoggable(ULogType type, String? tag) => true;
}
//
// // user.g.dart 将在我们运行生成命令后自动生成
// part 'flutter_ulog_test.g.dart';
//
// ///这个标注是告诉生成器，这个类是需要生成Model类的
// @JsonSerializable()
// class User{
//   User(this.name, this.email);
//
//   String name;
//   String email;
//   //不同的类使用不同的mixin即可
//   factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
//   Map<String, dynamic> toJson() => _$UserToJson(this);
// }


// Handles any object that is causing JsonEncoder() problems
Object toEncodableFallback(dynamic object) {
  return object.toString();
}
void main() {
  test('adds one to input values', () {
    // ULog.init((value){
    //   return ;
    // });
    ULog.addLogAdapter(consoleAdapter());
    ULog.v("12321321\ndfafdasfdsa\ndafdasf");
    ULog.d("12321321");
    ULog.i("12321321");
    ULog.w("12321321");
    ULog.e("1321231",error: NullThrownError());
    var map = [];
    map.add("1232");
    map.add("1232");
    map.add("1232");
    map.add("1232");
    ULog.e(map,error: NullThrownError());
    ULog.json(''' 
     {
      "a1": "value",
    "a2": 42,
    "bs": [
    {
    "b1": "any value",
    "b2": 13
    },
    {
    "b1": "another value",
    "b2": 0
    }
    ] 
    }
    ''');

    // ULog.o(User("123","123"));
    ULog.e("1321231",error: NullThrownError(),tag: "12312");
    ULog.e("123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321123213211232132112321321");
    try {
      throw StateError('This is a Dart exception.');
    } catch (e, stack) {
      ULog.e("1321231",error: e , stackTrace: stack,tag: "12312");

    }


  });
}
